import { EggAppConfig, PowerPartial } from "egg";

const redisConfig = {
  port: 6379, // Redis port
  host: "127.0.0.1",
  password: "",
};

export default () => {
  const config: PowerPartial<EggAppConfig> = {};

  config.logger = {
    level: "DEBUG",
    outputJSON: true,
    consoleLevel: "DEBUG",
  };

  config.io = {
    init: {}, // passed to engine.io
    namespace: {
      "/notify": {
        connectionMiddleware: ["notify"],
        packetMiddleware: [],
      },
    },
    redis: {
      host: redisConfig.host,
      port: redisConfig.port,
      auth_pass: redisConfig.password,
      db: 1,
    },
  };

  config.redis = {
    client: {
      port: redisConfig.port, // Redis port
      host: redisConfig.host, // Redis host
      password: redisConfig.password,
      db: 0,
    },
  };

  return config;
};
